$("#scheduler").kendoScheduler({
    height: 600,
    views: [
        {type: "day"},
        {type: "workWeek", selected: true},
        {type: "month"},
        {type: "agenda"}
    ],
    timezone: "Etc/UTC",
    dataSource: {
        batch: true,
        transport: {
            read: {
                url: appBosch.crud.read,
                dataType: "json"
            },
            update: {
                url: appBosch.crud.update,
                dataType: "json"
            },
            create: {
                url: appBosch.crud.create,
                dataType: "json"
            },
            destroy: {
                url: appBosch.crud.destroy,
                dataType: "json"
            },
            parameterMap: function(options, operation) {
                if (operation !== "read" && options.models) {
                    return {models: kendo.stringify(options.models)};
                }
            }
        },
        schema: {
            model: {
                id: "id",
                fields: {
                    title: {from: "title", text: "Titulo", validation: {required: true}, hidden: true},
                    test_id: {
                        from: "test_id",
                        validation: {
                            required: true
                        },
                        defaultValue: appBosch.tests[0].value
                    },
                    room_id: {defaultValue: appBosch.rooms[0].value},
                    start: {type: "date", from: "start"},
                    end: {type: "date", from: "end"},
                    startTimezone: {from: "start_timezone"},
                    endTimezone: {from: "end_timezone"},
                    description: {from: "description"},
                    recurrenceId: {from: "recurrence_id"},
                    recurrenceRule: {from: "recurrence_rule"},
                    recurrenceException: {from: "recurrence_exception"},
                    isAllDay: {type: "boolean", from: "is_all_dDay"}
                }
            }
        }
    },
    resources: [
        {
            field: "room_id",
            name: "room",
            dataSource: appBosch.rooms,
            title: "Sala"
        },
        {
            field: "test_id",
            name: "test",
            dataSource: appBosch.tests,
            title: "Examen"
        }
    ]
});

$(":checkbox").change(function(e) {
    var scheduler = $("#scheduler").data("kendoScheduler");

    scheduler.options.snap = this.checked;
    scheduler.view(scheduler.view().name);
});